# -*- coding: utf-8 -*-
"""
Development Environment Settings

Configuration for local development environment.
"""

from typing import List
from pydantic import Field
from .base import BaseSettings


class DevelopmentSettings(BaseSettings):
    """
    Development environment configuration
    
    Optimized for local development with debug features enabled.
    """
    
    environment: str = Field(default="development", description="Environment name")
    
    # Debug Configuration
    debug: bool = Field(default=True, description="Enable debug mode")
    reload: bool = Field(default=True, description="Enable auto-reload")
    
    # API Configuration
    api_host: str = Field(default="0.0.0.0", description="API host")
    api_port: int = Field(default=8004, description="API port")
    
    # CORS - More permissive for development
    cors_origins: List[str] = Field(
        default=[
            "http://localhost:3000",
            "http://localhost:8080",
            "http://127.0.0.1:3000",
            "http://127.0.0.1:8080",
        ],
        description="Allowed CORS origins"
    )
    
    # Logging - More verbose
    log_level: str = Field(default="DEBUG", description="Logging level")
    log_file: str = Field(
        default="logs/market_data_service_dev.log",
        description="Log file path"
    )
    
    # Cache - Shorter TTL for development
    cache_l1_ttl: int = Field(default=60, description="L1 cache TTL (1 min)")
    cache_l2_ttl: int = Field(default=300, description="L2 cache TTL (5 min)")
    cache_l3_ttl: int = Field(default=600, description="L3 cache TTL (10 min)")
    
    # Database - Local instances
    influxdb_url: str = Field(
        default="http://localhost:8086",
        description="InfluxDB URL"
    )
    influxdb_token: str = Field(
        default="dev-token",
        description="InfluxDB token (development)"
    )
    influxdb_org: str = Field(
        default="redfire_org",
        description="InfluxDB organization"
    )
    influxdb_bucket: str = Field(
        default="redfire_bucket_dev",
        description="InfluxDB bucket (development)"
    )
    
    redis_host: str = Field(default="localhost", description="Redis host")
    redis_port: int = Field(default=6379, description="Redis port")
    redis_password: str = Field(default="", description="Redis password")
    redis_db: int = Field(default=0, description="Redis database")
    
    # Resilience - More lenient for development
    resilience_cb_failure_threshold: int = Field(
        default=10,
        description="Higher threshold for development"
    )
    resilience_rate_limit_requests: int = Field(
        default=1000,
        description="Higher rate limit for development"
    )
    
    # Monitoring - More frequent checks
    monitoring_check_interval: float = Field(
        default=30.0,
        description="More frequent health checks"
    )
    monitoring_metrics_interval: float = Field(
        default=15.0,
        description="More frequent metrics collection"
    )
    
    # Performance - Smaller pools for development
    worker_pool_size: int = Field(
        default=2,
        description="Smaller worker pool for development"
    )
    max_concurrent_requests: int = Field(
        default=5,
        description="Lower concurrency for development"
    )
    
    # Data retention - Shorter for development
    data_retention_days: int = Field(
        default=30,
        description="30 days retention for development"
    )
    
    class Config:
        env_prefix = "DEV_"
        env_file = ".env.development"
        env_file_encoding = "utf-8"
        case_sensitive = False
        extra = "ignore"

